import React from 'react';
import { connect } from 'dva';

import ReactEcharts from 'echarts-for-react';

class ChartData extends React.Component {


    getOption=() => {
        const {serName1,
            serName2,
            xData,
            valueArr,
            coinArr}=this.props.plan;
        return {
            title: {
                text: '成就折线图'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: [serName1,serName2]
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: xData
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: serName1,
                    type: 'line',
                    stack: '总量',
                    data: valueArr
                },
                {
                    name: serName2,
                    type: 'line',
                    stack: '总量',
                    data: coinArr
                },
               
            ]
        };
        
    };
    
  render() {
    return (
      <ReactEcharts
        option={this.getOption()}
        notMerge={true}
        lazyUpdate={true}
        theme={'theme_name'}
        // onChartReady={this.onChartReadyCallback}
        // onEvents={EventsDict}
        // opts={}
      />
    );
  }
}

export default connect(({ plan }) => ({ plan }))(ChartData);
